<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        const arr = [1, 2, ['a', 'b', 'c'], 3, 4, [5, 6, 7, 8, [9, 10, 1, 23, 6, 43, 6, 7, 8, [123, 4, 5, 6, 7, 8]]]];
        const isArray = (arr) => Object.prototype.toString.call(arr) === '[object Array]';
        // 递归
        const flat = (arr, temp) => {
            if (!arr) return [];
            arr.map((item) => {
                if (isArray(item)) {
                    flat(item, temp);
                } else {
                    temp.push(item);
                }
            });
            return temp;
        }
        
        // toString
        const flat2 = (arr) => arr.toString().split(',');

        console.log('flat ====>', flat2(arr));
    </script>
</body>

</html>